package camarotialex.ferreiraantonio.lista;

import java.util.List;

import com.example.projeto_noticias.Noticia;
import com.squareup.picasso.Picasso;

import android.content.Context;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class NoticiasAdapter extends ArrayAdapter<Noticia>{

	public NoticiasAdapter(Context context, List<Noticia> noticias) {
		super(context,0, noticias);
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(resource, null);
		}
		Noticia noticia = getItem(position);
		
		ImageView mImg = (ImageView) convertView.findViewById(id);
		TextView mTitulo = (TextView) convertView.findViewById(id);
		TextView mData = (TextView) convertView.findViewById(id);
		
		Picasso.with(getContext()).load(noticia.imagem).noFade().into(mImg);
		mTitulo.setText(noticia.titulo);
		mData.setText(noticia.data);
		
		
		return convertView;
	}

}
